
        Page({
          data: {
              wrongQuestions: [], 
              select: "",
              status: "",
              list: [{
                title:" 急性上呼吸道感染的病原体多为",
                option:["支原体","链球菌 ","病毒 ","杆菌"],
                answer:"C"
               },
               {
                 title:" 关于急性上呼吸道感染的治疗，下述哪种说法不妥",
                 option:["目前尚无特效抗病毒药物 B应常规使用抗菌素","主要为对症治疗和中医治疗","多饮水、注意室内空气流通","适当休息，注意保暖"],
                 answer:"B"
                 
                },
                {
                 title:"  慢支是指",
                 option:["气管粘膜炎症","气管及周围组织的慢性炎症 "," 气管、支气管及其周围组织慢性炎症","细支气管及肺泡的炎症 E以上都不是"],
                 answer:"C"
                },
                {
                 title:" 慢性支气管炎发病和发展的一个重要因素是",
                 option:["吸烟","感染 ","大气污染 ","呼吸道防御功能降低 Ｅ寒冷气侯"],
                 answer:"A"
                },
                {
                 title:" 关于慢性支气管炎的临床表现，下列哪项是正确的？",
                 option:["咳嗽、咯痰白天明显 ","肺部罗音多在背部及肺底部 Ｄ肺部听诊不应有哮鸣音 "," 以脓性痰为主，偶有咯血","以上都不是"],
                 answer:"D"
                }
                
             ],
              answerNow: 0,
              optionList: ["A", "B", "C", "D"],
              successNum: 0,
              failNum: 0,
          },
      
          selectAnswer(e) {
              const { item } = e.currentTarget.dataset;
              const answer = this.data.list[this.data.answerNow].answer;

              if (item == answer) {
                  this.setData({
                      select: item,
                      status: "succes",
                      successNum: this.data.successNum + 1,
                  });
              } else {
                const currentQuestion = this.data.list[this.data.answerNow];  
                // 将错误的题目添加到wrongQuestions数组中  
                const wrongQuestions = this.data.wrongQuestions;  
                wrongQuestions.push(currentQuestion);  
                  this.setData({
                      wrongQuestions: wrongQuestions,
                      select: item,
                      status: "fail",
                      failNum: this.data.failNum + 1,
                  }); 
                const app = getApp(); 
                app.globalData.wrongQuestions = this.data.wrongQuestions;    
                app.globalData.num = this.data.successNum;
              }
      
              if (this.data.answerNow === this.data.list.length - 1) {
                  wx.showModal({
                      title: "恭喜你",
                      content: `你已完成所有题目, 共答对${this.data.successNum}道题, 共答错${this.data.failNum}道题, 请再接再厉!`,
                      showCancel: false,
                    
                  });
              } else {
                  setTimeout(() => {
                      this.setData({
                          answerNow: this.data.answerNow + 1,
                          status: "",
                          select: "",
                      });
                  }, 500);
              }
          },
          collectQuestion: function () {
            // 获取当前题目
            let currentQuestion1 = this.data.list[this.data.answerNow];
            // 将当前题目添加到全局集合中
            getApp().globalData.collectedQuestions.push(currentQuestion1);
            wx.showToast({
                title: '收藏成功',
                icon: 'success',
                duration: 2000
            });
          },
      
          onLoad() {
           
          },
      
        
          showWrongAnswers() {
              const wrongAnswers = wx.getStorageSync('wrongAnswers');
              if (wrongAnswers && wrongAnswers.length) {
                  wrongAnswers.forEach((question, index) => {
                      console.log(`${index + 1}. 题目: ${question.title}`);
                      console.log(`   用户答案: ${question.userAnswer}`);
                      console.log(`   正确答案: ${question.correctAnswer}`);
                  });
              } else {
                  console.log("暂无错题记录");
              }
          }
      });
      // 根据answerNow这个索引从list数组中获取对应项的answer属性